#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Desc: The demo of link attributes to values

attributes = ['name', 'dob', 'bender']
values = [['jason', '2000-01-01', 'male'], ['mike', '2001-02-02', 'male'], ['nancy', '1997-07-07', 'female']]


# Method 1 
lst = []
for v in values:
    d = {}  # 每次循环初始化一个空字典
    for vi in range(len(v)):
        d[attributes[vi]] = v[vi]
    lst.append(d)
print(lst)

# Method 2
res = [{k: v for i, k in enumerate(attributes) for j,v in enumerate(vd) if i == j} for vd in values]
print(res)

# Method 3
res1 = [dict(zip(attributes, v)) for v in values]
print(res1)

